package com.keba.lamp.complaint.enumeration;


import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.stream.Stream;

@Getter
@AllArgsConstructor
@NoArgsConstructor
@Schema(description = "账户收入支出类型-枚举")
public enum TransactionTypeEnum {
    /**
     * 收入
     */
    INCOME("收入",1),

    /**
     * 支出
     */
    EXPENSE("支出",2),;


    private String desc;

    private Integer code;

    public static TransactionTypeEnum getByCode(Integer code) {

        return Stream.of(TransactionTypeEnum.values())
                .filter(p -> p.getCode().equals(code))
                .findAny()
                .orElse(null);
    }
}
